package org.linloong.modules.apis.monitor.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.linloong.config.typehandler.GenericListTypeHandler;

import java.util.List;

@Data
@TableName("t_device_info")
@Schema(name = "DeviceInfo", description = "设备信息实体（对应文档\"气象设备接口\"章节Response）")
public class DeviceInfo {
    @TableId(type = IdType.ASSIGN_UUID)
    @Schema(description = "自定义主键（UUID）", example = "123e4567-e89b-12d3-a456-426614174000")
    private String id;

    @Schema(description = "设备唯一编号（文档中\"deviceId\"字段，如ZW101569）", example = "ZW101569")
    private String deviceId;

    @TableField(typeHandler = GenericListTypeHandler.class)
    @Schema(description = "传感器布局（文档中\"layout数组\"）")
    private List<SensorLayout> layout;

    /**
     * 传感器布局模型（文档"气象设备接口"章节Layout字段）
     */
    @Data
    @Schema(name = "SensorLayout", description = "传感器布局子实体（文档\"气象设备接口\"章节Layout数组）")
    public static class SensorLayout {
        @Schema(description = "传感器名称（如\"三秒平均风向\"）", example = "三秒平均风向")
        private String name;

        @Schema(description = "计量单位（如\"°\"）", example = "°")
        private String unit;

        @Schema(description = "K值（文档中用于后台计算）", example = "1.0")
        private Float k;

        @Schema(description = "B值（文档中用于后台计算）", example = "0.0")
        private Float b;

        @Schema(description = "数据位置顺序（匹配dataArray索引，从0开始）", example = "0")
        private Integer serial;

        @Schema(description = "描述（如\"3米\"）", example = "3米")
        private String description;

        @Schema(description = "传感器类型（如\"windDirection\"）", example = "windDirection")
        private String type;
    }
}